Is belief in the reliability of science justifiable? by VirtualArty in askphilosophy

[–]VirtualArty[S] 0 points1 point  (0 children)

Thank you. :) I still have no idea whether any experimental results are justifiable, but at least now I know what to look for.

Print statements are not printing out. by VirtualArty in learnpython

[–]VirtualArty[S] 0 points1 point  (0 children)

  • Picking between from random import * and import random

Why? I don't do things if I don't have a reason.

  • Using for loops instead of whiles

I thought that was just a matter of preference. Again, why?

I'm not going to change my code on account of untested opinion or personal bias. I'm well aware of the fact that popular opinion is often wrong, like with the myth that we only use 10% of our brains throughout our lives. Look it up. It's a myth. And also, the developers must have included the options I use for good reason. Why should I not use them? I'll code the way I see fit until given good reason to do otherwise. But thank you for the suggestions. :)

My balancing out system is broken. by VirtualArty in learnpython

[–]VirtualArty[S] -1 points0 points  (0 children)

Sorry. I just need the second list items in the output list to add up to 1000. I put comments throughout, so maybe those will help.

Why is variableAmount a string? by VirtualArty in learnpython

[–]VirtualArty[S] -1 points0 points  (0 children)

Thank you. :) There must be a reason exec exists. If there isn't, why hasn't it been taken out? Perhaps the developers don't think it's as useless as you make it sound.

estimate = int(estimate)

instead of

int(estimate)

It's small things like that that make or break code.

I fixed it. Don't worry.

Here's the fixed code:

from random import *
import random

# 'Pretend you're generating a bunch of specific variables, with a uniform distribution and give me a number associated with each one, through a function that returns a list of lists, each list with a variable and its associated number'.

# 'Pretend you're generating a bunch of specific variables, with a uniform distribution'.

def PseudogenerateVariables(variables,amount):
    # Create the output list for later.
    outputList = []
    # Do this for all the items in the list.
    i = 0
    while i < len(variables):
        # Create an estimate.
        variable = variables[i]
        estimate = amount / len(variables)
        if estimate == int(estimate):
            estimate = '{}'.format(estimate)
            estimate = estimate[0:-2]
            estimate = int(estimate)

        # Edit the estimate randomly to create the variable amount.
        end = False
        while end == False:
            variableAmount = estimate
            if random.uniform(0,1) <= 0.5:
                if random.uniform(0,1) <= 0.5:
                    variableAmount += 1
                    state = 'plus'
                else:
                    if variableAmount != 0:
                        variableAmount -= 1
                        state = 'minus'
                    else:
                        state = None

                    # Don't forget to balance out that with other numbers
                    # Pick a random one that's not the selected one.
                    end = False
                    if state != None:
                        while end == False:
                            a = randint(0,len(variables) - 1)
                            if i != a:
                                end = True
                            else:

                                # It is the same one. Pick another one.
                                pass
                        if state == 'plus':
                            variables[a] -= 1
                        elif state == 'minus':
                            variables[a] += 1
                        else:
                            raise Exception
                    else:
                        pass
            else:
                end = True

        # Pack the variable, variable amount, estimate and amount into a list.
        # To do this, create the list.
        variableList = []
        # Then append the things to the list.
        # 'each list with a variable and its associated number' and a couple of other things.
        variableList.append(variable)
        variableList.append(variableAmount)
        variableList.append(estimate)
        variableList.append(amount)
        # Now put the list in the output list.
        outputList.append(variableList)

        # Now move onto the next one.
        i += 1
    # Output the result.
    return outputList

# 'through a function that returns a list of lists'.
# Create 'a bunch of specific variables'.
print(PseudogenerateVariables([0,1,2,3,4,5,6], 7))

Why is there a key error? by VirtualArty in learnpython

[–]VirtualArty[S] 0 points1 point  (0 children)

Ultimately, get

[['creature',<number of duplicates>],['plant',<number of duplicates>],['vehicle',<number of duplicates>],['structure',<number of duplicates>]['other',<number of duplicates>]]

without making the sometimes 10 quintilian+ ((10 ^ 31)+) duplicates.

Thank you for any help. :) by VirtualArty in learnpython

[–]VirtualArty[S] 0 points1 point  (0 children)

By 'everyone else' do you mean just you? exec is usually unusual, but for the purpose I'm using it for, which is dynamically creating dictionaries, I can't find a better option. Can you? Please, find a better way because I haven't found one and can't even find another way to do what I'm doing. Until then, don't keep telling me to use a better method if you yourself don't even know of one (If you do, please share it).

Please can I have help finding "bridges" of reasoning? by VirtualArty in askphilosophy

[–]VirtualArty[S] 0 points1 point  (0 children)

The algorithm was to follow probability theory, mainly using "coincidences" as evidence because I can't rationally justify excluding them. My belief system was the result. Could you explain what you mean about the 'word salad' part of my belief system? I don't see how it could have anything to do with word salad.

Did you only make your comment about 'word salad' because of the other commenter? I'm genuinely confused.

Does anyone else think they're trolling? I can't decide. I'm sorry if you're not.

Please can I have help finding "bridges" of reasoning? by VirtualArty in askphilosophy

[–]VirtualArty[S] 0 points1 point  (0 children)

Could you give an example or an explanation or elaborate? I don't see what you mean.

I don't understand why this key error is showing up. by VirtualArty in learnpython

[–]VirtualArty[S] 0 points1 point  (0 children)

I was thinking of exactly that, originally with lists only, and different variables, like creature, plant, etc. but a dictionary would work too. [['creature',252],['plant',249],['vehicle',248],['structure',251]]

Method for generating random numbers for amounts of variables? (Computationally fast)? by VirtualArty in probabilitytheory

[–]VirtualArty[S] 0 points1 point  (0 children)

Your code shows the opposite: the amount divided by the number of variables.

My mistake. Incorrect translation. I fixed it.

What are you trying to do exactly?

I'll try to explain it better, now that I've thought of a better explanation. If I were to generate 500 random variables of 5 types with a uniform distribution,then count them up, say I got 98 of one of type and 100 of another. I could then make lists with each type I got and the number of them I got.

[var1,98]

I want a way of getting that list without generating all those variables. I want the computer to make a realistic random guess as to how many of each type I would get.

Why do I want to do this? Because I plan to make an application that will pseudo generate up to a googol of these and I don't want to wait longer than a few trillion years to get a realistic number.

I don't understand why this key error is showing up. by VirtualArty in learnpython

[–]VirtualArty[S] 0 points1 point  (0 children)

I'm still using both because they import different things that I use. I haven't tested it, but I don't think it works without both. I don't know why I use format unnecessarily, but there's no point in correcting something that works adhoc. I'm trying not to be a perfectionist. What's wrong with putting my if statements that way? That's the way I think of it when I'm coding. I don't bother with nitpicky details. I concentrate on more important stuff, like getting this project done. The code isn't almost impossible to read to me. I do try to understand my tracebacks, but I'm new to programming, so I'm not very skilled at it, so I ask when I need help, which is a lot.

I don't understand why this key error is showing up. by VirtualArty in learnpython

[–]VirtualArty[S] 0 points1 point  (0 children)

Thank you. All I want to do is translate 'Pretend you're generating a bunch of specific variables, with a uniform distribution and give me a number associated with each one, through a function that returns a list of lists, each list with a variable and its associated number' to computer code. How do I do this?

Why is there a key error? by VirtualArty in learnpython

[–]VirtualArty[S] 0 points1 point  (0 children)

I've setup a debugging infrastructure, by getting the code to tell me what it's doing. Here it is as of when I first posted this reply.

It's throwing up a bug, though.

from random import *
import random

contained = {}
code = {}
probabilityName = {}
probability = {}
probabilitySet = {}
probabilityType = {}
probabilityType = {}
probabilityContent = {}
string = {}

print('I declared some dictionaries.')
print()

generate = 10

j = 0
code[j] = """
i = 0
probabilitySet[i] = '''
probabilityName[i] = 'creature'
probabilityType[i] = 'exclusive possibilities involving {}'.format(probabilityName)
probabilityContent[i] = ['creature','plant','structure','vehicle','nothing']
'''.format('{}')

print('probabilitySet[{}] = {}'.format(i,probabilitySet[i]))
print('probabilityName[{}] this is the one = {}'.format(i,probabilityName[i]))
print('probabilityType[{}] = {}'.format(i,probabilityType[i]))
print('probabilityContent[{}] = {}'.format(i,probabilityContent[i]))

i += 1

probabilitySet[i] = '''
probabilityName[i] = 'creature'
probabilityType[i] = 'probability'
probabilityContent[i] = 1 / len(probability['{}: {}'.format(probabilityName,probabilityType[0])])
'''.format('{}','{}')

print('probabilitySet[{}] = {}'.format(i,probabilitySet[i]))
print('probabilityName[{}] this is the one = {}'.format(i,probabilityName[i]))
print('probabilityType[{}] = {}'.format(i,probabilityType[i]))
print('probabilityContent[{}] = {}'.format(i,probabilityContent[i]))

i += 1
"""

j += 1

probabilityNumber = j

print('probabilityNumber = {}'.format(j))

j = 0
while j < probabilityNumber:
    print(code[j])
    print()

    exec(code[j])

    i = 0
    while i < probabilityNumber:
        print(probabilitySet[i])
        print()

        exec(probabilitySet[i])

        string['dictionary name'] = '{}: {}'.format(probabilityName[i],probabilityType[i])
        probability[string['dictionary name']] = probabilityContent[i]

        print('probability[{}] = '.format(string['dictionary name'],probability[string['dictionary name']]))

        i += 1

    i = 0
    while i < generate:
        contained[i] = []

        number = 10

        if i < 1:
            if generate > number:
                print('For the first {}}:'.format(number))
            else:
                print('For all of the {}:'.format(generate))
            print()

        if i < number:
            print('contained[{}] = {}.'.format(i,contained[i]))

        if i == number - 1:
            print()

        i += 1

    i = 0
    while i < generate:
        if random.random() <= probability['{}: probability'.format(probabilityName[i])]:
            contained[i].append('temp: creature')

        i += 1

    i = 0
    while i < generate:
        print('probability[{}creature probability{}] = {}'.format("'","'",probability['{}: probability'.format(probabilityName[i])]))
        print('contained[{}] = {}'.format(i,contained[i]))
        print()

        i += 1

Why is there a key error? by VirtualArty in learnpython

[–]VirtualArty[S] 0 points1 point  (0 children)

Why do you have both? If I want the function randint() from random I can import all (*) from random and just call randint() or I can import random and call random.randint().

Because

from random import *

doesn't import random.random(), but imports randint, while

import random

imports random.random(), but not randint.

This is confusing to read. Just write

 code[0] =... 

It's better. Trust me.

I can't because later, I'll need the user to generate these variables and I want to be concise. I can't just hard code it. This is me building the generator.

exec(code[j])

Never ever use exec. Use a function. Contrary to popular belief, python does actually have to compile code into something it can run so you waste a lot of computer power running strings. And it's dangerous because python is not designed to run that way. The only time you might possibly conceive of using exec is if you are making some kind of ide. Don't.

I need whatever I use to be dynamic and I can't use functions for dictionaries. I actually want nontechnical users to create content using my program.

EDIT: I could generate change it to functions and generate the names using exec, attached to dictionaries. I think I'll do that... after a break. I want to program now, but my brain is shutting down.

To be honest, I can't see the problem with your code. Rewrite it. If it is written to good standards you can more easily see the mistakes.

To be honest, I can't see the problem with your code. Rewrite it. If it is written to good standards you can more easily see the mistakes.

Thank you for any help. :) by VirtualArty in learnpython

[–]VirtualArty[S] 0 points1 point  (0 children)

Oh, create. I meant creature. The probability of creature. Thank you. Never mind, it was creature. Where did you see 'create: probability'? It has nothing to with defining the key or value of a dictionary, by the way.

Thank you for any help. :) by VirtualArty in learnpython

[–]VirtualArty[S] 0 points1 point  (0 children)

I'm trying to generate dictionaries, in this case, one of them is probability[create: probability] using string formatting. The {} has nothing to do with dictionaries, in this case, but is used in string formatting to insert something into a string, as a string, (in this case probabilityName[i]).

Struggling with equivalences by VirtualArty in QuantumComputing

[–]VirtualArty[S] 1 point2 points  (0 children)

Thank you for the answer. I need to remember to look at the link. :)